package lance.honeydew.util;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

import org.apache.log4j.Logger;

public class SerialNumberUtil {

	private static final Logger logger = Logger.getLogger(SerialNumberUtil.class);
	
	public static final String TABLE_NAME_ITEMINFORMATION = "item_information";
	
	public static final String TABLE_NAME_ORDERINFORMATION = "order_information";
	
	/**
	 * generateSerialNumber
	 * @param date
	 * @param number
	 * @param length
	 * @return
	 */
	public static String generateSerialNumber(Date date, String number, int length) {
		
		String result = "";
		
		try {
			
			SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd", Locale.TAIWAN);
			String head = sdf.format(date);
			result += head;
			
			for (int i = 0; i < length; i++) {
				number = "0" + number;
			}
			
			result += number;
			
		} catch(Exception e) {
			logger.debug(e);
		}
		
		return result;
	}
}
